package com.weishenai.Utils;

import org.junit.Test;

import java.lang.ref.SoftReference;
import java.util.HashMap;
import java.util.Map;

/**
 * @Auther: weishenai
 * @Date: 2021/10/09/8:54
 * @Description:
 */
public class GetParamMeterMapUtils {
    public static Map<String, String> getParamMeterMap(String param) {
        String[] res = param.split("&");
        Map<String, String> result = new HashMap<>();
        for (String p : res) {
            String paramName = (String) getResultMap(p).get("paramName");
            String paramValue = (String) getResultMap(p).get("paramValue");
            result.put(paramName, paramValue);
        }

        return result;
    }

    private static Map<String, Object> getResultMap(String param) {
        Map<String, Object> result = new HashMap<>();
        String[] paramInfo = param.split("=");
        result.put("paramName", paramInfo[0]);
        result.put("paramValue", paramInfo[1]);
        return result;
    }
}
